﻿using System;
using System.ComponentModel;

using SBPweb.GoogleDataAPI.Client.Connector.Services.ClientService;

namespace SBPweb.GoogleDataAPI.Client.Connector.Services.PhotoService
{

    internal partial class PhotoProvider :
        ClientProvider<PhotoServiceClient, IPhotoService>,
        IPhotoProvider
    {

        #region Constructor logic

        public PhotoProvider()
            : base()
        {
            Client.AuthenticateCompleted += new EventHandler<AuthenticateCompletedEventArgs>(AuthenticateCompleted);
            Client.DoStuffCompleted += new EventHandler<AsyncCompletedEventArgs>(DoStuffCompleted);
        }

        #endregion

        #region Methods

        #region Operations

        public void DoStuff()
        {
            using (GetScope())
            {
                Client.DoStuffAsync(this);
            }
        }

        protected void DoStuffCompleted(object sender, AsyncCompletedEventArgs e)
        {
            if (e.UserState != this)
            {
                return;
            }
        }

        #endregion

        #region Overridden

        protected override void Authenticating(string userName, string password)
        {
            Client.AuthenticateAsync(userName, password, this);
        }

        protected void AuthenticateCompleted(object sender, AuthenticateCompletedEventArgs e)
        {
            base.AuthenticateCompleted(sender, e);
        }

        protected internal override string GetCryptographycSalt(string extra)
        {
            return string.Format("80799C07-383A-464b-8731-CEE8ABA3F294-{0}", extra);
        }

        #endregion

        #endregion

    }

}